package cn.sofwin.project.src.entity;

import cn.sofwin.project.src.service.CallService;
import cn.sofwin.project.src.service.NetService;
import cn.sofwin.project.src.service.SendService;

// 超人套餐
public class SuperPackage extends ServicePackage implements CallService, SendService, NetService {
    // 通话时间
    public double talkTime = 200;
    // 短信数量
    public double smsCount = 100;
    // 流量
    public double flow = 1;
    // 通话服务
    public CallService callService;

    public void showInfo(){
        System.out.println("通话时长:" + talkTime + "分钟");
        System.out.println("短信条数:" + smsCount + "条");
        System.out.println("上网流量：" + flow + "GB");
    }
    // 使用网络
    public void netPlay(double flow, MobileCard card){
        this.flow -= flow;
        // 超过套餐的消费
        if(this.flow <= 0){
            card.consumAmount += 0.2 * (flow - this.flow);
            card.money -= card.consumAmount;
            this.flow = 0;
        }
        card.realFlow += flow;
    }

    @Override
    public void call(int minCount, MobileCard card) {
        talkTime -= minCount;
        // 超过套餐的消费
        if(talkTime <= 0){
            card.consumAmount += 0.2 * (minCount - talkTime);
            card.money -= card.consumAmount;
            talkTime = 0;
        }
        card.realTalkTime += minCount;
    }

    @Override
    public void send(int count, MobileCard card) {
        smsCount -= count;
        // 超过套餐的消费
        if(smsCount <= 0){
            card.consumAmount += 0.1 * (count - smsCount);
            card.money -= card.consumAmount;
            smsCount = 0;
        }
        card.realSMSCCount += count;
    }
}
